The Visual Basic installed base has grown tremendously since its introduction as a programming tool. It has quickly become the development platform of choice for a wide range of applications. Writing network utilities and network aware applications using Visual Basic for Windows is a natural. With just a little help from your favorite C compiler, the power of NetWare could easily be at your fingertips.
There have been a number of articles on calling Novells own DLLs from Visual Basic but, if you want to get maximum control, flexibility and support for networks other than NetWare, you have two options:
Write your own DLLs.
Buy an add-on network package with support for multiple networks, source code, documentation and demonstration programs.
If you are going to write your own DLLs, you must first decide on a C compiler. I like the Microsoft Visual C/C++ one. It is a high quality tool and comes with an excellent debugger, CodeView for Windows. Also, documentation on interfacing DLLs with this compiler are available from Microsoft on CompuServe. Once youve decided on the tools, you are ready to write some code. My recommendation is to start simple. Writing high quality DLLs can get real complicated in the blink of an eye.
I have prepared a demonstration program for this article which is simple and useful. It is a program to check the security equivalences of a Bindery Object.
Microsoft Visual C/C++ .DEF code:
LIBRARY SECEQUIV
EXETYPE WINDOWS
DESCRIPTION 'Security Equivalence Demo'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 8192
EXPORTS
WEP PRIVATE
Microsoft Visual C/C++ C DLL code:
// some includes
#include <dos.h>
#include <fcntl.h>
#include <io.h>
#include <malloc.h>
#include <memory.h>
#include <share.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <windows.h>
// Read property value request structure
struct readPropertyValueRequest
{
WORD length;
BYTE req_no;
WORD object_type;
BYTE object_name_length;
BYTE object_name[48];
BYTE segment_number;
BYTE property_name_length;
BYTE property_name[16];
};
// Read property value reply structure
struct readPropertyValueReply
{
WORD length;
BYTE property_value[128];
BYTE more_segments;
BYTE property_flags;
};
// return structure for Visual Basic
// we just want to return the Bindery Object IDs
// found in the 128 Byte property_value element
typedef struct
{
LONG object_ID[31];
} gSecEquiv;
// Returns: completion code, array of Bindery Object IDs
// Accepts: Bindery Object Name
int FAR PASCAL _export NW_SecurityEquivalence(char far *cName,
struct gSecEquiv *SEquiv)
{
struct readPropertyValueRequest request;
struct readPropertyValueReply reply;
int i=0,ccode;
HINSTANCE hNetWareDrv;
LONG object=0, objectID[31];
long (FAR PASCAL *NetWareRequest) (void);
NetWareRequest = NULL;
// See if the NETWARE.DRV module is loaded
// and attempt to obtain a handle.
hNetWareDrv = GetModuleHandle("NETWARE");
// If there is a handle, perform the function.
if(hNetWareDrv > HINSTANCE_ERROR)
{
// Initialize the request and reply structures.
_fmemset(&request, 0x00, sizeof(request));
_fmemset(&reply, 0x00, sizeof(reply));
// Put the Bindery Object Name into the request structure.
_fstrcpy(request.object_name, cName);
// Obtain the Bindery Object Names length. request.object_name_length=sizeof(request.object_name);
You can enhance this program by using the supervisor Bindery Object ID and comparing it to the returned values to check for supervisor equivalence. Also, in the basic program you could return the non-zero values to a list box for selection and use into another function. Remember that the values returned are in Hi-Lo format.
Using Visual Basic for Windows 3.0 with C may just give you the best of all worlds.
Stephen Casella is the author of NetPak Professional, a multi-network add-on library for Visual Basic for Windows and Visual Basic for MS-DOS. NetPak Professional supports, NetWare 2.X, 3.X, 4.X and Windows for Workgroups and is sold by Crescent Software, Inc. in Ridgefield, Connecticut. It can be ordered by calling (203-438-5300).